package us.mooresr.aircraftscheduling.client.events;

import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.EventHandler;
import us.mooresr.aircraftscheduling.shared.model.Reservation;
import com.google.gwt.event.shared.HasHandlers;
import com.google.gwt.event.shared.HandlerRegistration;

public class ReservationDeletedEvent extends
		GwtEvent<ReservationDeletedEvent.ReservationDeletedHandler> {

	public static Type<ReservationDeletedHandler> TYPE = new Type<ReservationDeletedHandler>();
	private Reservation reservation;

	public interface ReservationDeletedHandler extends EventHandler {
		public void onReservationDeleted(ReservationDeletedEvent event);
	}

	public interface ReservationDeletedHasHandlers extends HasHandlers {
		public HandlerRegistration addReservationDeletedHandler(
				ReservationDeletedHandler handler);
	}

	public ReservationDeletedEvent(Reservation reservation) {
		this.reservation = reservation;
	}

	public Reservation getReservation() {
		return reservation;
	}

	@Override
	protected void dispatch(ReservationDeletedHandler handler) {
		handler.onReservationDeleted(this);
	}

	@Override
	public Type<ReservationDeletedHandler> getAssociatedType() {
		return TYPE;
	}

	public static Type<ReservationDeletedHandler> getType() {
		return TYPE;
	}

	public static void fire(HasHandlers source, Reservation reservation) {
		source.fireEvent(new ReservationDeletedEvent(reservation));
	}
}
